import Vue from "vue"
import VueRouter from "vue-router"


Vue.use(VueRouter)

const routes = [{
    path: "/login",
    component: () => import('../views/login/login.vue')
  },
  {
    path: "/register",
    component: () => import('../views/register/Register.vue')
  },
  {
    path: "/forgetpwd",
    component: () => import('../views/login/forgetpwd.vue')
  },
  {
    path: "/",
    redirect: "/mainsubject"
  },
  {
    path: "/home",
    component: () => import('../views/home/Home'),
    children: [{
        path: "/mainpage",
        component: () => import('../views/mainpages/MainPage.vue'),
        children: [{
            path: "/mainsubject",
            component: () => import('../views/mainpages/MainSubject.vue'),
            children: [{
                path: "/recommend",
                component: () => import('../views/mainpages/Recommend.vue')
              },
              {
                path: "/cares",
                component: () => import('../views/mainpages/Cares.vue')
              },
              {
                path: "/hostlist",
                component: () => import('../views/mainpages/Hostlist.vue')
              }
            ]
          },
          {
            path: "/question",
            component: () => import('../views/question/Question.vue')
          },
          {
            path: "/search",
            name:"search",
            component: () => import('../views/mainpages/Search.vue')
          },
        ]
      },
      {
        path: "/writetopic",
        component: () => import('../views/topic/WriteTopic.vue')
      },
      {
        path: "/topicdetail/:type/:id",
        name: "topicdetail",
        component: () => import('../views/topic/TopicDetail.vue')
      },
      {
        path: "/otheruserpage",
        name: "otheruserpage",
        component: () => import('../views/otherMainPage/OtherUserPage.vue'),
        children: [{
            path: "/othertopic",
            component: () => import('../views/otherMainPage/child/OtherTopic.vue')
          },
          {
            path: "/otherissue",
            component: () => import('../views/otherMainPage/child/OtherIssue.vue')
          },
          {
            path: "/otherreply",
            component: () => import('../views/otherMainPage/child/OtherReply.vue')
          }
        ]
      },
      {
        path: "/personpage",
        component: () => import('../views/Pages/PersonPage.vue'),
        children: [{
            path: "/mytopic",
            component: () => import('../views/Pages/child/MyTopic.vue')
          },
          {
            path: "/collect",
            component: () => import('../views/Pages/child/Collect.vue'),
            children: [{
                path: "/collect_topic",
                component: () => import('../views/Pages/child/Collect_topic.vue')
              },
              {
                path: "/collect_answer",
                component: () => import('../views/Pages/child/Collect_answer.vue'),
              }
            ]
          },
          {
            path: "/attention",
            component: () => import('../views/Pages/child/Attention.vue'),
            children: [{
                path: "/collect_issue",
                component: () => import('../views/Pages/child/Collect_issue.vue')
              },
              {
                path: "/attention_user",
                component: () => import('../views/Pages/child/Attention_user.vue'),
              }
            ]
          },
          {
            path: "/history",
            component: () => import('../views/Pages/child/History.vue'),
            children: [
              {
                path:"/history_topic",
                component:() => import('../views/Pages/child/History_topic.vue')
              },
              {
                path:"/history_issue",
                component:() => import('../views/Pages/child/History_issue.vue')
              },
              {
                path:"/history_user",
                component:() => import('../views/Pages/child/History_user.vue'),
              }]
          }
        ]
      },
      {
        path: "/updatedetails",
        component: () => import('../views/Pages/UpdateDetails.vue')
      },
    ]
  },
]

const router = new VueRouter({
  routes,
  mode: "history"
})

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router